package init;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;

import sql.DBManagment;
import sql.record.*;

public class Install {
	public static void main(String[] args) {
		try {
			//Creating the DB
			DBManagment.createDB();
			//Creating tables
			User user = new User();
			DBManagment.createTable(user);
			user.userName = "Admin";
			user.givenName = "Admin";
			user.surName = "Admin";
			user.phoneNumber = "555555555";
			user.password = "Admin";
			user.type = 1;
			List<TableRecord> recList = new LinkedList<TableRecord>();
			recList.add(user);
			try{
			DBManagment.insertRecord(recList);
			}catch(Exception e){
				
			}
			Course course = new Course();
			DBManagment.createTable(course);
			
			CourseSchedule courseSchedule = new CourseSchedule();
			DBManagment.createTable(courseSchedule);
			
			Registration registration = new Registration();
			DBManagment.createTable(registration);

		} catch (ClassNotFoundException e) {
			System.err.println("Error: failed to innitialize the DB");
			e.printStackTrace(); //TODO: Remove!
		} catch (SQLException e) {
			System.err.println("Error: failed to innitialize the DB");
			e.printStackTrace(); //TODO: Remove!
		}
	}
}
